#include <sys/types.h>
#include <video/text_terminal.h>

extern void isr000( void );
extern void isr001( void );
extern void isr002( void );
extern void isr003( void );
extern void isr004( void );
extern void isr005( void );
extern void isr006( void );
extern void isr007( void );
extern void isr008( void );
extern void isr009( void );
extern void isr010( void );
extern void isr011( void );
extern void isr012( void );
extern void isr013( void );
extern void isr014( void );
extern void isr015( void );
extern void isr016( void );
extern void isr017( void );
extern void isr018( void );
extern void isr019( void );
extern void isr020( void );
extern void isr021( void );
extern void isr022( void );
extern void isr023( void );
extern void isr024( void );
extern void isr025( void );
extern void isr026( void );
extern void isr027( void );
extern void isr028( void );
extern void isr029( void );
extern void isr030( void );
extern void isr031( void );
extern void isr032( void );
extern void isr033( void );
extern void isr034( void );
extern void isr035( void );
extern void isr036( void );
extern void isr037( void );
extern void isr038( void );
extern void isr039( void );
extern void isr040( void );
extern void isr041( void );
extern void isr042( void );
extern void isr043( void );
extern void isr044( void );
extern void isr045( void );
extern void isr046( void );
extern void isr047( void );
extern void isr048( void );
extern void isr049( void );
extern void isr050( void );
extern void isr051( void );
extern void isr052( void );
extern void isr053( void );
extern void isr054( void );
extern void isr055( void );
extern void isr056( void );
extern void isr057( void );
extern void isr058( void );
extern void isr059( void );
extern void isr060( void );
extern void isr061( void );
extern void isr062( void );
extern void isr063( void );
extern void isr064( void );
extern void isr065( void );
extern void isr066( void );
extern void isr067( void );
extern void isr068( void );
extern void isr069( void );
extern void isr070( void );
extern void isr071( void );
extern void isr072( void );
extern void isr073( void );
extern void isr074( void );
extern void isr075( void );
extern void isr076( void );
extern void isr077( void );
extern void isr078( void );
extern void isr079( void );
extern void isr080( void );
extern void isr081( void );
extern void isr082( void );
extern void isr083( void );
extern void isr084( void );
extern void isr085( void );
extern void isr086( void );
extern void isr087( void );
extern void isr088( void );
extern void isr089( void );
extern void isr090( void );
extern void isr091( void );
extern void isr092( void );
extern void isr093( void );
extern void isr094( void );
extern void isr095( void );
extern void isr096( void );
extern void isr097( void );
extern void isr098( void );
extern void isr099( void );
extern void isr100( void );
extern void isr101( void );
extern void isr102( void );
extern void isr103( void );
extern void isr104( void );
extern void isr105( void );
extern void isr106( void );
extern void isr107( void );
extern void isr108( void );
extern void isr109( void );
extern void isr110( void );
extern void isr111( void );
extern void isr112( void );
extern void isr113( void );
extern void isr114( void );
extern void isr115( void );
extern void isr116( void );
extern void isr117( void );
extern void isr118( void );
extern void isr119( void );
extern void isr120( void );
extern void isr121( void );
extern void isr122( void );
extern void isr123( void );
extern void isr124( void );
extern void isr125( void );
extern void isr126( void );
extern void isr127( void );
extern void isr128( void );
extern void isr129( void );
extern void isr130( void );
extern void isr131( void );
extern void isr132( void );
extern void isr133( void );
extern void isr134( void );
extern void isr135( void );
extern void isr136( void );
extern void isr137( void );
extern void isr138( void );
extern void isr139( void );
extern void isr140( void );
extern void isr141( void );
extern void isr142( void );
extern void isr143( void );
extern void isr144( void );
extern void isr145( void );
extern void isr146( void );
extern void isr147( void );
extern void isr148( void );
extern void isr149( void );
extern void isr150( void );
extern void isr151( void );
extern void isr152( void );
extern void isr153( void );
extern void isr154( void );
extern void isr155( void );
extern void isr156( void );
extern void isr157( void );
extern void isr158( void );
extern void isr159( void );
extern void isr160( void );
extern void isr161( void );
extern void isr162( void );
extern void isr163( void );
extern void isr164( void );
extern void isr165( void );
extern void isr166( void );
extern void isr167( void );
extern void isr168( void );
extern void isr169( void );
extern void isr170( void );
extern void isr171( void );
extern void isr172( void );
extern void isr173( void );
extern void isr174( void );
extern void isr175( void );
extern void isr176( void );
extern void isr177( void );
extern void isr178( void );
extern void isr179( void );
extern void isr180( void );
extern void isr181( void );
extern void isr182( void );
extern void isr183( void );
extern void isr184( void );
extern void isr185( void );
extern void isr186( void );
extern void isr187( void );
extern void isr188( void );
extern void isr189( void );
extern void isr190( void );
extern void isr191( void );
extern void isr192( void );
extern void isr193( void );
extern void isr194( void );
extern void isr195( void );
extern void isr196( void );
extern void isr197( void );
extern void isr198( void );
extern void isr199( void );
extern void isr200( void );
extern void isr201( void );
extern void isr202( void );
extern void isr203( void );
extern void isr204( void );
extern void isr205( void );
extern void isr206( void );
extern void isr207( void );
extern void isr208( void );
extern void isr209( void );
extern void isr210( void );
extern void isr211( void );
extern void isr212( void );
extern void isr213( void );
extern void isr214( void );
extern void isr215( void );
extern void isr216( void );
extern void isr217( void );
extern void isr218( void );
extern void isr219( void );
extern void isr220( void );
extern void isr221( void );
extern void isr222( void );
extern void isr223( void );
extern void isr224( void );
extern void isr225( void );
extern void isr226( void );
extern void isr227( void );
extern void isr228( void );
extern void isr229( void );
extern void isr230( void );
extern void isr231( void );
extern void isr232( void );
extern void isr233( void );
extern void isr234( void );
extern void isr235( void );
extern void isr236( void );
extern void isr237( void );
extern void isr238( void );
extern void isr239( void );
extern void isr240( void );
extern void isr241( void );
extern void isr242( void );
extern void isr243( void );
extern void isr244( void );
extern void isr245( void );
extern void isr246( void );
extern void isr247( void );
extern void isr248( void );
extern void isr249( void );
extern void isr250( void );
extern void isr251( void );
extern void isr252( void );
extern void isr253( void );
extern void isr254( void );
extern void isr255( void );

struct idt_ptr {
    u16 limit;
    u64 base_addr;
} __attribute__((packed)) ;


struct __attribute__((packed)) idt_entry {
    u16 target_offset_low;
    u16 target_selector;
    u16 flags;
    u16 target_offset_mid;
    u32 target_offset_upper;
    u32 reserved;
};


struct idt_entry IDT_ENTRIES[256];
struct idt_ptr   IDT_PTR;
term_entry*      IDT_TERM_ENTRY;

void idt_init( term_entry* te ) {
    u16 i;
    u64* t;

    IDT_TERM_ENTRY = te;

    // set each entry to type = interrupt, but set all other values to 0 (including
    // selector, function address and present flag)
    for (i = 0; i < 256; i++) {
        t = (u64*)&IDT_ENTRIES[i];
        t[0] = 0x0000000000000000;
        t[1] = 0x00000e0000000000;
    }

    IDT_PTR.base_addr = (u64)IDT_ENTRIES;
    IDT_PTR.limit     = sizeof( IDT_ENTRIES ) - 1;
}


void idt_set_entry( u8 num, u64 func_addr, u16 sel, u8 present, u8 dpl, u8 ist ) {
    u16 flags = present ? 0x8e00 : 0x0e00;
    flags |= ((u16)dpl & 0x03) << 13;
    flags |= (u16)ist & 0x07;

    IDT_ENTRIES[num].target_offset_low   = (u16)func_addr;
    IDT_ENTRIES[num].target_selector     = sel;
    IDT_ENTRIES[num].flags               = flags;
    IDT_ENTRIES[num].target_offset_mid   = (u16)(func_addr >> 16);
    IDT_ENTRIES[num].target_offset_upper = (u32)(func_addr >> 32);
    IDT_ENTRIES[num].reserved            = 0x00000000;
}


void idt_install( void ) {
    asm volatile( "lidt %0" : : "m"(IDT_PTR) );
}


void idt_set_all_stock( u8 selector ) {
    idt_set_entry( 0, (u64)isr000, selector, 1, 0, 0 );
    idt_set_entry( 1, (u64)isr001, selector, 1, 0, 0 );
    idt_set_entry( 2, (u64)isr002, selector, 1, 0, 0 );
    idt_set_entry( 3, (u64)isr003, selector, 1, 0, 0 );
    idt_set_entry( 4, (u64)isr004, selector, 1, 0, 0 );
    idt_set_entry( 5, (u64)isr005, selector, 1, 0, 0 );
    idt_set_entry( 6, (u64)isr006, selector, 1, 0, 0 );
    idt_set_entry( 7, (u64)isr007, selector, 1, 0, 0 );
    idt_set_entry( 8, (u64)isr008, selector, 1, 0, 0 );
    idt_set_entry( 9, (u64)isr009, selector, 1, 0, 0 );
    idt_set_entry( 10, (u64)isr010, selector, 1, 0, 0 );
    idt_set_entry( 11, (u64)isr011, selector, 1, 0, 0 );
    idt_set_entry( 12, (u64)isr012, selector, 1, 0, 0 );
    idt_set_entry( 13, (u64)isr013, selector, 1, 0, 0 );
    idt_set_entry( 14, (u64)isr014, selector, 1, 0, 0 );
    idt_set_entry( 15, (u64)isr015, selector, 1, 0, 0 );
    idt_set_entry( 16, (u64)isr016, selector, 1, 0, 0 );
    idt_set_entry( 17, (u64)isr017, selector, 1, 0, 0 );
    idt_set_entry( 18, (u64)isr018, selector, 1, 0, 0 );
    idt_set_entry( 19, (u64)isr019, selector, 1, 0, 0 );
    idt_set_entry( 20, (u64)isr020, selector, 1, 0, 0 );
    idt_set_entry( 21, (u64)isr021, selector, 1, 0, 0 );
    idt_set_entry( 22, (u64)isr022, selector, 1, 0, 0 );
    idt_set_entry( 23, (u64)isr023, selector, 1, 0, 0 );
    idt_set_entry( 24, (u64)isr024, selector, 1, 0, 0 );
    idt_set_entry( 25, (u64)isr025, selector, 1, 0, 0 );
    idt_set_entry( 26, (u64)isr026, selector, 1, 0, 0 );
    idt_set_entry( 27, (u64)isr027, selector, 1, 0, 0 );
    idt_set_entry( 28, (u64)isr028, selector, 1, 0, 0 );
    idt_set_entry( 29, (u64)isr029, selector, 1, 0, 0 );
    idt_set_entry( 30, (u64)isr030, selector, 1, 0, 0 );
    idt_set_entry( 31, (u64)isr031, selector, 1, 0, 0 );
    idt_set_entry( 32, (u64)isr032, selector, 1, 0, 0 );
    idt_set_entry( 33, (u64)isr033, selector, 1, 0, 0 );
    idt_set_entry( 34, (u64)isr034, selector, 1, 0, 0 );
    idt_set_entry( 35, (u64)isr035, selector, 1, 0, 0 );
    idt_set_entry( 36, (u64)isr036, selector, 1, 0, 0 );
    idt_set_entry( 37, (u64)isr037, selector, 1, 0, 0 );
    idt_set_entry( 38, (u64)isr038, selector, 1, 0, 0 );
    idt_set_entry( 39, (u64)isr039, selector, 1, 0, 0 );
    idt_set_entry( 40, (u64)isr040, selector, 1, 0, 0 );
    idt_set_entry( 41, (u64)isr041, selector, 1, 0, 0 );
    idt_set_entry( 42, (u64)isr042, selector, 1, 0, 0 );
    idt_set_entry( 43, (u64)isr043, selector, 1, 0, 0 );
    idt_set_entry( 44, (u64)isr044, selector, 1, 0, 0 );
    idt_set_entry( 45, (u64)isr045, selector, 1, 0, 0 );
    idt_set_entry( 46, (u64)isr046, selector, 1, 0, 0 );
    idt_set_entry( 47, (u64)isr047, selector, 1, 0, 0 );
    idt_set_entry( 48, (u64)isr048, selector, 1, 0, 0 );
    idt_set_entry( 49, (u64)isr049, selector, 1, 0, 0 );
    idt_set_entry( 50, (u64)isr050, selector, 1, 0, 0 );
    idt_set_entry( 51, (u64)isr051, selector, 1, 0, 0 );
    idt_set_entry( 52, (u64)isr052, selector, 1, 0, 0 );
    idt_set_entry( 53, (u64)isr053, selector, 1, 0, 0 );
    idt_set_entry( 54, (u64)isr054, selector, 1, 0, 0 );
    idt_set_entry( 55, (u64)isr055, selector, 1, 0, 0 );
    idt_set_entry( 56, (u64)isr056, selector, 1, 0, 0 );
    idt_set_entry( 57, (u64)isr057, selector, 1, 0, 0 );
    idt_set_entry( 58, (u64)isr058, selector, 1, 0, 0 );
    idt_set_entry( 59, (u64)isr059, selector, 1, 0, 0 );
    idt_set_entry( 60, (u64)isr060, selector, 1, 0, 0 );
    idt_set_entry( 61, (u64)isr061, selector, 1, 0, 0 );
    idt_set_entry( 62, (u64)isr062, selector, 1, 0, 0 );
    idt_set_entry( 63, (u64)isr063, selector, 1, 0, 0 );
    idt_set_entry( 64, (u64)isr064, selector, 1, 0, 0 );
    idt_set_entry( 65, (u64)isr065, selector, 1, 0, 0 );
    idt_set_entry( 66, (u64)isr066, selector, 1, 0, 0 );
    idt_set_entry( 67, (u64)isr067, selector, 1, 0, 0 );
    idt_set_entry( 68, (u64)isr068, selector, 1, 0, 0 );
    idt_set_entry( 69, (u64)isr069, selector, 1, 0, 0 );
    idt_set_entry( 70, (u64)isr070, selector, 1, 0, 0 );
    idt_set_entry( 71, (u64)isr071, selector, 1, 0, 0 );
    idt_set_entry( 72, (u64)isr072, selector, 1, 0, 0 );
    idt_set_entry( 73, (u64)isr073, selector, 1, 0, 0 );
    idt_set_entry( 74, (u64)isr074, selector, 1, 0, 0 );
    idt_set_entry( 75, (u64)isr075, selector, 1, 0, 0 );
    idt_set_entry( 76, (u64)isr076, selector, 1, 0, 0 );
    idt_set_entry( 77, (u64)isr077, selector, 1, 0, 0 );
    idt_set_entry( 78, (u64)isr078, selector, 1, 0, 0 );
    idt_set_entry( 79, (u64)isr079, selector, 1, 0, 0 );
    idt_set_entry( 80, (u64)isr080, selector, 1, 0, 0 );
    idt_set_entry( 81, (u64)isr081, selector, 1, 0, 0 );
    idt_set_entry( 82, (u64)isr082, selector, 1, 0, 0 );
    idt_set_entry( 83, (u64)isr083, selector, 1, 0, 0 );
    idt_set_entry( 84, (u64)isr084, selector, 1, 0, 0 );
    idt_set_entry( 85, (u64)isr085, selector, 1, 0, 0 );
    idt_set_entry( 86, (u64)isr086, selector, 1, 0, 0 );
    idt_set_entry( 87, (u64)isr087, selector, 1, 0, 0 );
    idt_set_entry( 88, (u64)isr088, selector, 1, 0, 0 );
    idt_set_entry( 89, (u64)isr089, selector, 1, 0, 0 );
    idt_set_entry( 90, (u64)isr090, selector, 1, 0, 0 );
    idt_set_entry( 91, (u64)isr091, selector, 1, 0, 0 );
    idt_set_entry( 92, (u64)isr092, selector, 1, 0, 0 );
    idt_set_entry( 93, (u64)isr093, selector, 1, 0, 0 );
    idt_set_entry( 94, (u64)isr094, selector, 1, 0, 0 );
    idt_set_entry( 95, (u64)isr095, selector, 1, 0, 0 );
    idt_set_entry( 96, (u64)isr096, selector, 1, 0, 0 );
    idt_set_entry( 97, (u64)isr097, selector, 1, 0, 0 );
    idt_set_entry( 98, (u64)isr098, selector, 1, 0, 0 );
    idt_set_entry( 99, (u64)isr099, selector, 1, 0, 0 );
    idt_set_entry( 100, (u64)isr100, selector, 1, 0, 0);
    idt_set_entry( 101, (u64)isr101, selector, 1, 0, 0);
    idt_set_entry( 102, (u64)isr102, selector, 1, 0, 0);
    idt_set_entry( 103, (u64)isr103, selector, 1, 0, 0);
    idt_set_entry( 104, (u64)isr104, selector, 1, 0, 0);
    idt_set_entry( 105, (u64)isr105, selector, 1, 0, 0);
    idt_set_entry( 106, (u64)isr106, selector, 1, 0, 0);
    idt_set_entry( 107, (u64)isr107, selector, 1, 0, 0);
    idt_set_entry( 108, (u64)isr108, selector, 1, 0, 0);
    idt_set_entry( 109, (u64)isr109, selector, 1, 0, 0);
    idt_set_entry( 110, (u64)isr110, selector, 1, 0, 0);
    idt_set_entry( 111, (u64)isr111, selector, 1, 0, 0);
    idt_set_entry( 112, (u64)isr112, selector, 1, 0, 0);
    idt_set_entry( 113, (u64)isr113, selector, 1, 0, 0);
    idt_set_entry( 114, (u64)isr114, selector, 1, 0, 0);
    idt_set_entry( 115, (u64)isr115, selector, 1, 0, 0);
    idt_set_entry( 116, (u64)isr116, selector, 1, 0, 0);
    idt_set_entry( 117, (u64)isr117, selector, 1, 0, 0);
    idt_set_entry( 118, (u64)isr118, selector, 1, 0, 0);
    idt_set_entry( 119, (u64)isr119, selector, 1, 0, 0);
    idt_set_entry( 120, (u64)isr120, selector, 1, 0, 0);
    idt_set_entry( 121, (u64)isr121, selector, 1, 0, 0);
    idt_set_entry( 122, (u64)isr122, selector, 1, 0, 0);
    idt_set_entry( 123, (u64)isr123, selector, 1, 0, 0);
    idt_set_entry( 124, (u64)isr124, selector, 1, 0, 0);
    idt_set_entry( 125, (u64)isr125, selector, 1, 0, 0);
    idt_set_entry( 126, (u64)isr126, selector, 1, 0, 0);
    idt_set_entry( 127, (u64)isr127, selector, 1, 0, 0);
    idt_set_entry( 128, (u64)isr128, selector, 1, 0, 0);
    idt_set_entry( 129, (u64)isr129, selector, 1, 0, 0);
    idt_set_entry( 130, (u64)isr130, selector, 1, 0, 0);
    idt_set_entry( 131, (u64)isr131, selector, 1, 0, 0);
    idt_set_entry( 132, (u64)isr132, selector, 1, 0, 0);
    idt_set_entry( 133, (u64)isr133, selector, 1, 0, 0);
    idt_set_entry( 134, (u64)isr134, selector, 1, 0, 0);
    idt_set_entry( 135, (u64)isr135, selector, 1, 0, 0);
    idt_set_entry( 136, (u64)isr136, selector, 1, 0, 0);
    idt_set_entry( 137, (u64)isr137, selector, 1, 0, 0);
    idt_set_entry( 138, (u64)isr138, selector, 1, 0, 0);
    idt_set_entry( 139, (u64)isr139, selector, 1, 0, 0);
    idt_set_entry( 140, (u64)isr140, selector, 1, 0, 0);
    idt_set_entry( 141, (u64)isr141, selector, 1, 0, 0);
    idt_set_entry( 142, (u64)isr142, selector, 1, 0, 0);
    idt_set_entry( 143, (u64)isr143, selector, 1, 0, 0);
    idt_set_entry( 144, (u64)isr144, selector, 1, 0, 0);
    idt_set_entry( 145, (u64)isr145, selector, 1, 0, 0);
    idt_set_entry( 146, (u64)isr146, selector, 1, 0, 0);
    idt_set_entry( 147, (u64)isr147, selector, 1, 0, 0);
    idt_set_entry( 148, (u64)isr148, selector, 1, 0, 0);
    idt_set_entry( 149, (u64)isr149, selector, 1, 0, 0);
    idt_set_entry( 150, (u64)isr150, selector, 1, 0, 0);
    idt_set_entry( 151, (u64)isr151, selector, 1, 0, 0);
    idt_set_entry( 152, (u64)isr152, selector, 1, 0, 0);
    idt_set_entry( 153, (u64)isr153, selector, 1, 0, 0);
    idt_set_entry( 154, (u64)isr154, selector, 1, 0, 0);
    idt_set_entry( 155, (u64)isr155, selector, 1, 0, 0);
    idt_set_entry( 156, (u64)isr156, selector, 1, 0, 0);
    idt_set_entry( 157, (u64)isr157, selector, 1, 0, 0);
    idt_set_entry( 158, (u64)isr158, selector, 1, 0, 0);
    idt_set_entry( 159, (u64)isr159, selector, 1, 0, 0);
    idt_set_entry( 160, (u64)isr160, selector, 1, 0, 0);
    idt_set_entry( 161, (u64)isr161, selector, 1, 0, 0);
    idt_set_entry( 162, (u64)isr162, selector, 1, 0, 0);
    idt_set_entry( 163, (u64)isr163, selector, 1, 0, 0);
    idt_set_entry( 164, (u64)isr164, selector, 1, 0, 0);
    idt_set_entry( 165, (u64)isr165, selector, 1, 0, 0);
    idt_set_entry( 166, (u64)isr166, selector, 1, 0, 0);
    idt_set_entry( 167, (u64)isr167, selector, 1, 0, 0);
    idt_set_entry( 168, (u64)isr168, selector, 1, 0, 0);
    idt_set_entry( 169, (u64)isr169, selector, 1, 0, 0);
    idt_set_entry( 170, (u64)isr170, selector, 1, 0, 0);
    idt_set_entry( 171, (u64)isr171, selector, 1, 0, 0);
    idt_set_entry( 172, (u64)isr172, selector, 1, 0, 0);
    idt_set_entry( 173, (u64)isr173, selector, 1, 0, 0);
    idt_set_entry( 174, (u64)isr174, selector, 1, 0, 0);
    idt_set_entry( 175, (u64)isr175, selector, 1, 0, 0);
    idt_set_entry( 176, (u64)isr176, selector, 1, 0, 0);
    idt_set_entry( 177, (u64)isr177, selector, 1, 0, 0);
    idt_set_entry( 178, (u64)isr178, selector, 1, 0, 0);
    idt_set_entry( 179, (u64)isr179, selector, 1, 0, 0);
    idt_set_entry( 180, (u64)isr180, selector, 1, 0, 0);
    idt_set_entry( 181, (u64)isr181, selector, 1, 0, 0);
    idt_set_entry( 182, (u64)isr182, selector, 1, 0, 0);
    idt_set_entry( 183, (u64)isr183, selector, 1, 0, 0);
    idt_set_entry( 184, (u64)isr184, selector, 1, 0, 0);
    idt_set_entry( 185, (u64)isr185, selector, 1, 0, 0);
    idt_set_entry( 186, (u64)isr186, selector, 1, 0, 0);
    idt_set_entry( 187, (u64)isr187, selector, 1, 0, 0);
    idt_set_entry( 188, (u64)isr188, selector, 1, 0, 0);
    idt_set_entry( 189, (u64)isr189, selector, 1, 0, 0);
    idt_set_entry( 190, (u64)isr190, selector, 1, 0, 0);
    idt_set_entry( 191, (u64)isr191, selector, 1, 0, 0);
    idt_set_entry( 192, (u64)isr192, selector, 1, 0, 0);
    idt_set_entry( 193, (u64)isr193, selector, 1, 0, 0);
    idt_set_entry( 194, (u64)isr194, selector, 1, 0, 0);
    idt_set_entry( 195, (u64)isr195, selector, 1, 0, 0);
    idt_set_entry( 196, (u64)isr196, selector, 1, 0, 0);
    idt_set_entry( 197, (u64)isr197, selector, 1, 0, 0);
    idt_set_entry( 198, (u64)isr198, selector, 1, 0, 0);
    idt_set_entry( 199, (u64)isr199, selector, 1, 0, 0);
    idt_set_entry( 200, (u64)isr200, selector, 1, 0, 0);
    idt_set_entry( 201, (u64)isr201, selector, 1, 0, 0);
    idt_set_entry( 202, (u64)isr202, selector, 1, 0, 0);
    idt_set_entry( 203, (u64)isr203, selector, 1, 0, 0);
    idt_set_entry( 204, (u64)isr204, selector, 1, 0, 0);
    idt_set_entry( 205, (u64)isr205, selector, 1, 0, 0);
    idt_set_entry( 206, (u64)isr206, selector, 1, 0, 0);
    idt_set_entry( 207, (u64)isr207, selector, 1, 0, 0);
    idt_set_entry( 208, (u64)isr208, selector, 1, 0, 0);
    idt_set_entry( 209, (u64)isr209, selector, 1, 0, 0);
    idt_set_entry( 210, (u64)isr210, selector, 1, 0, 0);
    idt_set_entry( 211, (u64)isr211, selector, 1, 0, 0);
    idt_set_entry( 212, (u64)isr212, selector, 1, 0, 0);
    idt_set_entry( 213, (u64)isr213, selector, 1, 0, 0);
    idt_set_entry( 214, (u64)isr214, selector, 1, 0, 0);
    idt_set_entry( 215, (u64)isr215, selector, 1, 0, 0);
    idt_set_entry( 216, (u64)isr216, selector, 1, 0, 0);
    idt_set_entry( 217, (u64)isr217, selector, 1, 0, 0);
    idt_set_entry( 218, (u64)isr218, selector, 1, 0, 0);
    idt_set_entry( 219, (u64)isr219, selector, 1, 0, 0);
    idt_set_entry( 220, (u64)isr220, selector, 1, 0, 0);
    idt_set_entry( 221, (u64)isr221, selector, 1, 0, 0);
    idt_set_entry( 222, (u64)isr222, selector, 1, 0, 0);
    idt_set_entry( 223, (u64)isr223, selector, 1, 0, 0);
    idt_set_entry( 224, (u64)isr224, selector, 1, 0, 0);
    idt_set_entry( 225, (u64)isr225, selector, 1, 0, 0);
    idt_set_entry( 226, (u64)isr226, selector, 1, 0, 0);
    idt_set_entry( 227, (u64)isr227, selector, 1, 0, 0);
    idt_set_entry( 228, (u64)isr228, selector, 1, 0, 0);
    idt_set_entry( 229, (u64)isr229, selector, 1, 0, 0);
    idt_set_entry( 230, (u64)isr230, selector, 1, 0, 0);
    idt_set_entry( 231, (u64)isr231, selector, 1, 0, 0);
    idt_set_entry( 232, (u64)isr232, selector, 1, 0, 0);
    idt_set_entry( 233, (u64)isr233, selector, 1, 0, 0);
    idt_set_entry( 234, (u64)isr234, selector, 1, 0, 0);
    idt_set_entry( 235, (u64)isr235, selector, 1, 0, 0);
    idt_set_entry( 236, (u64)isr236, selector, 1, 0, 0);
    idt_set_entry( 237, (u64)isr237, selector, 1, 0, 0);
    idt_set_entry( 238, (u64)isr238, selector, 1, 0, 0);
    idt_set_entry( 239, (u64)isr239, selector, 1, 0, 0);
    idt_set_entry( 240, (u64)isr240, selector, 1, 0, 0);
    idt_set_entry( 241, (u64)isr241, selector, 1, 0, 0);
    idt_set_entry( 242, (u64)isr242, selector, 1, 0, 0);
    idt_set_entry( 243, (u64)isr243, selector, 1, 0, 0);
    idt_set_entry( 244, (u64)isr244, selector, 1, 0, 0);
    idt_set_entry( 245, (u64)isr245, selector, 1, 0, 0);
    idt_set_entry( 246, (u64)isr246, selector, 1, 0, 0);
    idt_set_entry( 247, (u64)isr247, selector, 1, 0, 0);
    idt_set_entry( 248, (u64)isr248, selector, 1, 0, 0);
    idt_set_entry( 249, (u64)isr249, selector, 1, 0, 0);
    idt_set_entry( 250, (u64)isr250, selector, 1, 0, 0);
    idt_set_entry( 251, (u64)isr251, selector, 1, 0, 0);
    idt_set_entry( 252, (u64)isr252, selector, 1, 0, 0);
    idt_set_entry( 253, (u64)isr253, selector, 1, 0, 0);
    idt_set_entry( 254, (u64)isr254, selector, 1, 0, 0);
    idt_set_entry( 255, (u64)isr255, selector, 1, 0, 0);
}


void isr_routine_does_not_exist( u8 isr_num ) {
    term_printf( IDT_TERM_ENTRY, "Unimplemented ISR for isr number [%x]\n", isr_num );
}

